package com.persagy.iot.utils

import com.persagy.iot.app.IOTApp.no_value
import com.persagy.iot.bean.IOTData
import com.persagy.iot.utils.IOTUtils.timestampConverter

import org.apache.flink.streaming.api.windowing.time.Time
import java.text.SimpleDateFormat


object TestFunction {

  def main1(args: Array[String]): Unit = {
    var data: String = "1101080259;4;report;20210111150020;58440;9919;1;11301;635.0;"

    val arr2 = data.split(";")

    val build: String = arr2(0)
    val sign: String = arr2(5)
    val eventTimeStr: String = arr2(3)
    val eventTime: Long = timestampConverter("yyyyMMddHHmmss", eventTimeStr, 0L)
    val sysTime: Long = System.currentTimeMillis()

    for (i <- 7 until (arr2.length, 2) if (!no_value.equals(arr2(i + 1)))) {
      val funId: String = arr2(i)
      val value: Double = arr2(i + 1).toDouble
      val status: Int = 1
      /** rowKey */
      val id = status + build + sign + funId

      /** 转为 iotData 实体类 */
      val iotData: IOTData = IOTData(id, build, sign, funId, value, eventTimeStr, eventTime, sysTime, 0L, status)
      println(iotData)
    }
  }

  def main(args: Array[String]): Unit = {
    val sdf: SimpleDateFormat = new SimpleDateFormat("yyyy MM dd HH:mm:ss")
    val result1=sdf.format(1610394300000L)
    val result2=sdf.format(1610393400000L)
    println(System.currentTimeMillis())
    val milliseconds: Long = Time.minutes(15).toMilliseconds
    val l: Long = System.currentTimeMillis() / milliseconds * milliseconds + milliseconds

    println(l)
    println(sdf.format(l))
  }
}
